package service;

import javax.script.ScriptException;

import model.PlayerStanding;

import org.springframework.transaction.annotation.Transactional;

import exceptions.DivisionByZeroException;
import exceptions.UnknownVariableException;

/**
 * Interface for PlayerStandingService.
 * @author Andre Melo
 * @author Marcus Leite 
 * @author Sergio Danilo
 *
 */
@Transactional
public interface PlayerStandingService {

	/**
	 * Define a standing expression to an specific league.
	 * @param leagueId The league that will receive the expression.
	 * @param expression The standing expression.
	 * @throws ScriptException If occurs a syntax error.
	 * @throws DivisionByZeroException If occurs a division by zero.
	 * @throws UnknownVariableException If appears an unknown variable in standing expression.
	 */
	void defineStandingsExpression(Integer leagueId, String expression) throws ScriptException, DivisionByZeroException, UnknownVariableException;

	/**
	 * Method that returns the standing of an specific player from an specific league.
	 * @param playerId The ID of the player.
	 * @param leagueId The ID of the league.
	 * @return The standing of the player.
	 * @throws ScriptException If occurs a syntax error.
	 * @throws DivisionByZeroException If occurs a division by zero.
	 * @throws UnknownVariableException If appears an unknown variable in standing expression.
	 */
	Object getPlayerStanding(Integer playerId, Integer leagueId) throws ScriptException, DivisionByZeroException, UnknownVariableException;
	
	/**
	 * Save the player standing of a player.
	 * @param ps The player standing.
	 */
	 void save(PlayerStanding ps);
	
	/**
	 * Update the player standing of a player.
	 * @param ps The player standing.
	 */
	 void update(PlayerStanding ps);
	
	/**
	 * Delete the player standing of a player.
	 * @param ps The player standing.
	 */
	 void delete(PlayerStanding ps);

	/**
	 * Remove all standings.
	 */
	 void removeAllStandings();
	
	/**
	 * Method that returns the instance of LeagueService.
	 * @return
	 */
	 LeagueService getLeagueService();

	/**
	 * Method that sets the instance of LeagueService.
	 * @param leagueService the leagueService to set
	 */
	void setLeagueService(LeagueService leagueService);

	/**
	 * Method that sets the instance of MatchService.
	 * @return the matchService
	 */
	 MatchService getMatchService();

	/**
	 * Method that sets the instance of MatchService.
	 * @param matchService the matchService to set
	 */
	void setMatchService(MatchService matchService);

}
